#include "GGE.h"

GGE_eMotion::GGE_eMotion()
{

}

int GGE_eMotion::KeyPress ( void )
{
  varGGE_MOUSEX = varGGE_EVENT_TYPE.motion.x;
  varGGE_MOUSEY = varGGE_EVENT_TYPE.motion.y;

  while ( SDL_PollEvent(&varGGE_EVENT_TYPE) || SDL_PollEvent(&varGGE_EVENT_TYPE) )
    {

      if( varGGE_EVENT_TYPE.type == SDL_MOUSEBUTTONDOWN )
        {
          if( varGGE_EVENT_TYPE.button.button == SDL_BUTTON_LEFT )
            {
              varGGE_KEYPRESS = gkey_MOUSE_BTT_LFT;
            }
          if( varGGE_EVENT_TYPE.button.button == SDL_BUTTON_MIDDLE )
            {
              varGGE_KEYPRESS = gkey_MOUSE_BTT_CNT;
            }
          if( varGGE_EVENT_TYPE.button.button == SDL_BUTTON_RIGHT )
            {
              varGGE_KEYPRESS = gkey_MOUSE_BTT_RGT;
            }
        }

      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_ESCAPE )
        {
          varGGE_KEYPRESS = gkey_ESC;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_UP )
        {
          varGGE_KEYPRESS = gkey_UP;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_DOWN )
        {
          varGGE_KEYPRESS = gkey_DOWN;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_LEFT )
        {
          varGGE_KEYPRESS = gkey_LEFT;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_RIGHT )
        {
          varGGE_KEYPRESS = gkey_RIGHT;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_SPACE )
        {
          varGGE_KEYPRESS = gkey_SPACE;
        }

      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_q )
        {
          varGGE_KEYPRESS = gkey_q;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_w )
        {
          varGGE_KEYPRESS = gkey_w;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_e )
        {
          varGGE_KEYPRESS = gkey_e;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_r )
        {
          varGGE_KEYPRESS = gkey_r;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_t )
        {
          varGGE_KEYPRESS = gkey_t;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_y )
        {
          varGGE_KEYPRESS = gkey_y;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_u )
        {
          varGGE_KEYPRESS = gkey_u;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_i )
        {
          varGGE_KEYPRESS = gkey_i;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_o )
        {
          varGGE_KEYPRESS = gkey_o;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_p )
        {
          varGGE_KEYPRESS = gkey_p;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_a )
        {
          varGGE_KEYPRESS = gkey_a;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_s )
        {
          varGGE_KEYPRESS = gkey_s;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_d )
        {
          varGGE_KEYPRESS = gkey_d;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_f )
        {
          varGGE_KEYPRESS = gkey_f;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_g )
        {
          varGGE_KEYPRESS = gkey_g;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_h )
        {
          varGGE_KEYPRESS = gkey_h;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_j )
        {
          varGGE_KEYPRESS = gkey_j;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_k )
        {
          varGGE_KEYPRESS = gkey_k;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_l )
        {
          varGGE_KEYPRESS = gkey_l;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_z )
        {
          varGGE_KEYPRESS = gkey_z;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_x )
        {
          varGGE_KEYPRESS = gkey_x;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_c )
        {
          varGGE_KEYPRESS = gkey_c;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_v )
        {
          varGGE_KEYPRESS = gkey_v;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_b )
        {
          varGGE_KEYPRESS = gkey_b;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_n )
        {
          varGGE_KEYPRESS = gkey_n;
        }
      if ( varGGE_EVENT_TYPE.key.keysym.sym == SDLK_m )
        {
          varGGE_KEYPRESS = gkey_m;
        }


    }
  if ( varGGE_EVENT_TYPE.type == SDL_KEYUP  || varGGE_EVENT_TYPE.type == SDL_MOUSEBUTTONUP  )
    {
      varGGE_KEYPRESS = 0;
    }
  fflush(stdin);
  return varGGE_KEYPRESS;
}

int GGE_eMotion::MouseX ()
{
  return varGGE_MOUSEX;
}

int GGE_eMotion::MouseY ()
{
  return varGGE_MOUSEY;
}
